# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=dynamips
pkgver=0.2.21
pkgrel=1
pkgdesc="Cisco router emulator"
url="https://github.com/GNS3/dynamips"
arch="all"
license="GPL-2.0"
makedepends="cmake libpcap-dev elfutils-dev linux-headers libnsl-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/GNS3/dynamips/archive/v$pkgver.tar.gz
	detect-byte-order.patch"

prepare() {
	sed -e "s:^set ( DYNAMIPS_FLAGS:#&:" -i cmake/dependencies.cmake
	default_prepare
}

build() {
	if [ $CARCH == x86_64 ]; then
		export DYNAMIPS_ARCH=amd64
	fi
	export CFLAGS="$CFLAGS -Wno-enum-compare"
	export CXXFLAGS="$CXXFLAGS -Wno-enum-compare"
	cmake -B build . \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX:PATH=/usr
	make -C build
}

package() {
	make -C build DESTDIR="$pkgdir" install
}

sha512sums="c7251963897b65ed5696f47f03be727cea79fe2245850c86fa6b4d8718afa10002b1e39bccefe1c7f2ba86fe6b8f52fe8663ee34f72ca3d9f846522b9b9b4d29  dynamips-0.2.21.tar.gz
d3beb4ddda4ca571a36f2333609db48126c0f6629adf39a985cedb1741356f415f33c82c56b69802955869c6741655476253c4ea4e8ef1461411cc52e411e429  detect-byte-order.patch"
